package com.牛客网.jd;

import java.util.Iterator;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class 合并两个集合 {

	public static void main(String[] args) {
		Scanner scanner=new Scanner(System.in);
		while(scanner.hasNext()){
			int count1=scanner.nextInt();
			int count2=scanner.nextInt();
			Set<Integer> numberset=new TreeSet<Integer>();
			for (int i = 0; i < count1+count2; i++) {
				numberset.add(scanner.nextInt());
			}
			int count=numberset.size();
			int index=1;
			for (Iterator iterator = numberset.iterator(); iterator.hasNext();) {
				Integer integer = (Integer) iterator.next();
				if(index==count){
					System.out.print(integer);
				}else{
					System.out.print(integer+" ");
				}
				index++;	
			}
		}
	}
}
